//gulp + sass + borwserSync

'use strict';

var gulp = require('gulp'),
    borwserSync = require('browser-sync').create(),
    reload = borwserSync.reload,
    watch = require('gulp-watch'),
    minifycss = require('gulp-clean-css'),
    rename = require('gulp-rename'),
    sass = require('gulp-sass');



gulp.task('sass', function() {
    return gulp.src('src/sass/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(rename({
            dirname: "/css",
            suffix: ".min"
        }))
        // .pipe(minifycss())
        .pipe(gulp.dest('dist/static'))
        .pipe(borwserSync.stream());
});

gulp.task('html', function() {
    return gulp.src('src/template/**/*.html')
        .pipe(gulp.dest('dist/template'));
});


gulp.task('serve', ['sass', 'html'], function() {
    borwserSync.init({
        server: {
            baseDir: './dist'
        }
    });

    gulp.watch('src/sass/**/*.scss', ['sass']);
    gulp.watch("src/template/**/*.html", ['html']).on('change', reload);
});


gulp.task('default', ['serve']);
